-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[mypyc] feat: new primitive for weakref.ref.__call__
#19145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
d535f84
to
3b71a7f
Compare
weakref.ref.__call__
f5c4cc8
to
e6e4a6b
Compare
This PR adds a new mypyc primitive for `weakref.ref` I wasn't able to figure out what name mypyc expects for `weakref.proxy`, so I took that out and will keep that for a separate PR later on. ref is more commonly used than proxy anyway. for later, I tried: - weakref.proxy - weakref.ProxyType - weakref.weakproxy no luck with those also for later, I'll need to finish #19145 to add a primitive for `weakref.ref.__call__`
e6e4a6b
to
49d9cc0
Compare
#endif | ||
|
||
|
||
PyObject *CPyWeakref_GetRef(PyObject *ref) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a new C function because of the variability of PyWeakref_GetRef
for more information, see https://pre-commit.ci
d219f8f
to
47ab0d4
Compare
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…into weakref-call
for more information, see https://pre-commit.ci
Is this still WIP? |
Ah no, this one is ready for review. Though I wouldn't call it "complete" quite yet. One open question, I'll add a comment in the code |
builder: IRBuilder, expr: CallExpr, callee: RefExpr | ||
) -> Value | None: | ||
"""Invoke the Specializer callback for a function if one has been registered""" | ||
if is_weakref_rprimitive(builder.node_type(callee)) and len(expr.args) == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's gotta be a better place for this, but I wasn't able to figure out how to make function_op or method_op work with the __call__
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JukkaL There's also one open question here blocking me, and then I can finish this up
edit: hmm. Well it was working, some recent change on master appears to have broken this one. So I guess we have 2 open questions as I don't particularly understand any of the cast
ing code.
for more information, see https://pre-commit.ci
weakref.ref.__call__
weakref.ref.__call__
This PR is a follow-up to #19099, adding a new rprimitive type for
weakref.ReferenceType
and another new custom_op primitive forweakref.ReferenceType.__call__
to dereference reference objects.